<script>
export default {
	globalData: {
		statusBarHeight: 0,
		statusBottomHeight: 0,
		headerHeight: '0px',
		otherHeight: '0px',
		deviceType: '',//mp-alipay支付宝   mp-weixin微信
	},
	onLaunch: function () {
		console.log('App Launch')

		const systemInfo = uni.getSystemInfoSync();
		console.log('systemInfo:', systemInfo);
		this.globalData.statusBarHeight = systemInfo.statusBarHeight;
		this.globalData.statusBottomHeight = systemInfo.safeAreaInsets?.bottom || 0;
		this.globalData.headerHeight = `calc(${systemInfo.statusBarHeight}px + 88rpx)`
		this.globalData.otherHeight = `calc(${systemInfo.statusBarHeight}px + ${this.globalData.statusBottomHeight}px + 88rpx)`
		this.globalData.deviceType = systemInfo.uniPlatform;
		console.log(this.globalData);


		if (this.globalData.deviceType == 'mp-weixin') {
			this.getWxCode();
		}

		if (this.$comFun.getUserToken()) {
			const userStanding = uni.getStorageSync('userStanding');
			if (userStanding) {
				this.$store.dispatch('setStanding', userStanding);
			}
		}
	},
	onShow: function () {
		console.log('App Show')
	},
	onHide: function () {
		console.log('App Hide')
	},
	methods: {
		getWxCode() {
			const that = this;
			uni.setStorageSync('wxLoginInfo', '');
			wx.login({
				success: async (wxRes) => {
					// console.log(wxRes);
					if (wxRes.code) {
						const res = await that.$request.post('mobile/wxLogin', {
							code: wxRes.code,
						});
						// console.log(res);
						if (res.code == 200) {
							uni.setStorageSync('wxLoginInfo', res.data);
						}
					}
				}
			})
		},
	}
}
</script>

<style lang="scss">
/*每个页面公共css */
@import "@/common/css/public.scss";
</style>
